(library (lib vector-procs)
  (export vector-contains?)
  (import
    (except (rnrs base) let-values map error vector-map)
    (only (guile) lambda* λ)
    ;; srfi-43 for vector procs
    (srfi srfi-43)))


(define vector-contains?
  (λ (vec searched equality-proc)
    "Look in a vector for an element, that is equal to the
given element under the given equality-proc. Note, that this
procedure does not take advantage of any optimization for
sorted vectors or similar things. It simply searches from
first to last element of the vector sequentially."
    (let ([max-ind (vector-length vec)])
      (let next ([ind 0])
        (cond
         [(= ind max-ind) #f]
         [(equality-proc (vector-ref vec ind) searched) #t]
         [else (next (+ ind 1))])))))
